<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title></title>
    <link rel="stylesheet" href="../style/ucs.css">
    <link rel="stylesheet" href="../content/font/iconfont.css">
    <link rel="stylesheet" href="../style/theme.css">
</head>
<body>
    <div id="giraffe"></div>
    <script type="text/javascript" src="../../dist/libs/u-eventhub.js"></script>
    <script type="text/javascript" src="../../dist/libs/engine.js"></script>
    <script type="text/javascript" src="../../dist/ucsmy-ui.js"></script>

    <script>
        var setTitle = new UDM({
            value:"支付密码"
        });
        var phoneDM = new UDM({
            value:"",
            label:"手机号：",
            placeholder:"请输入您的手机号",
            validator:[
                {type:"require",msg:"手机号码不能为空"},
                {type:"mobile",msg:"手机号码格式错误，请重新输入"}
            ]
        });
        var imgCodeDM = new UDM({
            label:"图形验证码：",
            placeholder:"请输入图形验证码",
            validator:[
                {type:"require",msg:"图形验证码不能为空"},
                {
                    type:"fn",
                    fn:function(v){
                        if(btnNext1DM.clicked ||msgBtnDM.clicked){
                            btnNext1DM.clicked = false;
                            msgBtnDM.clicked = false;
                            console.log('22')
                            return true;
                        }else{
                            console.log('333')
//                        return CheckImageCode('LoginImgCode', v);
                        }
                    },
                    msg:"短信验证码错误，请重新输入"
                }
            ]
        });
        var imgBtnDM = new UDM({
            value:"../content/images/code.jpg",
            onClick:function(){
                imgBtnDM.setValue("../content/images/logoe.jpg");
            }
        });

        /**
         * fn(v)：v是输入框中的value*/
        var msgCodeDM = new UDM({
            label:"短信验证码：",
            placeholder:"请输入短信验证码",
            validator:[
                {type:"require",msg:"验证码不能为空"},
                {
                    type:"fn",
                    fn:function(v){

//                        return CheckImageCode('LoginImgCode', v);
                    },
                    msg:"短信验证码错误，请重新输入"
                }
            ]
        });

        /**
         * @desc
         * onClick()：
         * count：倒计时秒数*/
        var msgBtnDM = new UDM({
            count:5,
            clicked:false,
            onMouseDown:function () {
                msgBtnDM.clicked = true;
            },
            onClick:function(){
//                if(phoneDM.validate() && imgCodeDM.validate()){
//                    console.log('倒计时')
//                    UEventHub.emit('getcode',msgBtnDM);
//                }else{
//                    console.log('验证没通过')
//                }
            }
        });

        /**
         * @desc
         * onClick()：
         *      UEventHub.emit('next','step1');  判断通过后添加发布事件,'step1'：当前第几步
         */
        var btnNext1DM = new UDM({
            clicked:false,
            onMouseDown:function () {
                btnNext1DM.clicked = true;
            },
            onClick:function(){
                console.log('btnNext1');
                UEventHub.emit('next','step1');

            }
        });

        /**
         * 第二步
         * */
        var step2pwdDM = new UDM({
            label:"新密码：",
            placeholder:"密码为6-16位字母、数字的组合",
            validator:[
                {type:"require",msg:"密码不能为空"},
                {
                    type:"fn",
                    fn:function(v){
                        pwdStrengthDM.setValue({
                            strength:"normal"
                        })
                    },
                    msg:"密码必须为6-16位字母、数字的组合"}
            ]
        });
        //密码强度
        var pwdStrengthDM = new UDM({
            value:{
                show:true,
                strength:"weak"//弱：weak  中：normal 强：strong
            }
        });
        var step2newPwdDM = new UDM({
            label:"确认密码：",
            placeholder:"请再次输入新密码",
            validator:[
                {type:"require",msg:"密码不能为空"},
                {
                    type:"fn",
                    fn:function(v){
                        if(v == step2pwdDM.getValue()){
                            return true;
                        }else{
                            return false;
                        }
                    },
                    msg:"两次密码输入不一致"
                }
            ]
        });

        /**
         * 第三步
         * */
        var step3DM = new UDM({
            value:{
                successTxt:"您已成功修改密码，请重新登录！",
                count:5,
                turnTxt:"登录页面",//跳转至文案
                turnLink:"../Index/index.html",//跳转至链接
                toText:"返回首页111",//直接跳转文案
                toLink:"../Index/index.html"//直接跳转链接
            }
        });

        /**
         * @desc btnNext2DM 重置密码中下一步按钮
         * onClick()：
         */
        var btnNext2DM = new UDM({
            onClick:function(){
                console.log('btnNext2');
                UEventHub.emit('next','step2');
            }
        });

        /**
        * 页面链接
         */
        var URLDM = new UDM({
            home:"../Index/index.html"  //返回首页
        });

        UEventHub.on('pageLoad',function(){
            //手机号码反显
            phoneDM.setValue("11111111111");
        });

        var PageDM = {
            URL:URLDM,
            phone:phoneDM,
            imgCode:imgCodeDM,
            imgBtn:imgBtnDM,
            msgCode:msgCodeDM,
            msgBtn:msgBtnDM,
            btnNext1:btnNext1DM,
            btnNext2:btnNext2DM,
            step2pwd:step2pwdDM,
            step2newPwd:step2newPwdDM,
            pwdStrength:pwdStrengthDM,
            step3:step3DM,
            setTitle:setTitle
        }
    </script>
<script type="text/javascript" src="../FindPwd\index.js"></script></body>
</html>